package com.fourth.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fourth.dao.BusinessDao;
import com.fourth.dao.ExamineDao;
import com.fourth.service.ExamineService;
import com.fourth.vo.EmpVo1;
import com.fourth.vo.ExamineVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ljx.entity.Examine;
import com.ljx.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author C-Q
 * @version 1.1.0
 * @Description: TODO
 * @date 2023/2/28
 */
@Service
public class ExamineServiceImpl extends ServiceImpl<ExamineDao, Examine> implements ExamineService {

    @Resource
    private ExamineDao examineDao;

    /**
     * 审查审核查全表
     * @param currentPage
     * @param pageSize
     * @param startTime
     * @param endTime
     * @return
     */
    @Override
    public Result examineSelect(Integer currentPage, Integer pageSize, String startTime, String endTime) {
        PageHelper.startPage(currentPage, pageSize);
        List<EmpVo1>  examines = examineDao.examineSelect(startTime,endTime);
        PageInfo<EmpVo1> pageInfo = new PageInfo<>(examines);
        return new Result(2000, "查询成功", pageInfo);
    }

    /**
     * 新增审查表数据
     * @param examine
     * @return
     * 备注：待使用
     */
    @Override
    public Result insertExamine(Examine examine) {
        int examine1 = examineDao.insertExamine(examine);
        return new Result(2000,"添加成功",examine1);
    }

    @Autowired(required = false)
    private BusinessDao businessDao;
    /**
     * 修改表中店铺对应的状态和停业原因
     * @param
     * @return
     */
    @Override
    public Result updateTableField(ExamineVo examineVo) {

        if(examineVo.getMsg()==null){
            int i = examineDao.updateTableField2(examineVo);
        }else {
             businessDao.updateBusinessStatus(examineVo);
            int i = examineDao.updateTableField(examineVo);

        }
        return new Result(2000,"修改成功");
    }
}
